<template>
	<view class="container bg-grey">
		<sb-back-icon />
		<u-cell-group :border="false">
			<u-cell-item title="个人信息" @click="$go2('/pages/main/setting/my-profile')" />
			<u-cell-item title="地址管理" @click="$go2('/pages/main/address/list')"></u-cell-item>
			<u-cell-item title="修改密码" @click="$go2(`./change-password.vue`)"></u-cell-item>
		</u-cell-group>
		<u-gap height="30"></u-gap>
		<view class="flex j-c">
			<u-button size="medium" type="error" class="flex j-c c-m padv50" shape="square" @click="logout">
				LOGOUT
			</u-button>
		</view>
	</view>
</template>

<script>
	import { TOKEN } from "@/config/constant";
	export default {
		data() {
			return {
				info: {},
			};
		},
		onLoad: function() {
			if (!this.$checkLogin()) return this.$redirect2Login();
			this.getInfo();
		},
		methods: {
			async getInfo() {
				let { success, data } = await this.$get("/user/getUserInfo");

				if (success) this.info = data;
			},
			// 退出登录
			async logout() {
				await this.$confirm("确定注销登录?");
				uni.removeStorageSync(TOKEN);
				try {
					let service = app.getIMService();
					service.Connection.disconnect();
				} catch (e) {}
				this.$go2("/pages/main/tabbar/index/index", true);
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container {
		/deep/.u-cell-item-box {
			border-radius: 20rpx;
		}

		.logout {
			border-radius: 20rpx;

			&::after {
				border: none;
			}
		}
	}
</style>
